// 服务管理接口

import request from '@/utils/request'

// 查看用户协议
export const getUserAgreement = () => {
  return request.get('/agreement/look/user')
}

// 更改用户协议
export const updateUserAgreement = ({ userAgreementHtml }) => {
  return request.post('/agreement/update/user', { userAgreementHtml })
}

// 查看隐私协议
export const getPrivacyAgreement = () => {
  return request.get('/agreement/look/privacy')
}

// 更改隐私协议
export const updatePrivacyAgreement = ({ privacyAgreementHtml }) => {
  return request.post('/agreement/update/privacy', { privacyAgreementHtml })
}

// 查看应用管理信息
export const getAppList = ({ page, size }) => {
  return request.get('/app/look', {
    params: {
      page,
      size
    }
  })
}

// 删除应用
export const deleteApp = ({ appId }) => {
  return request.get('/app/delete', {
    params: {
      appId
    }
  })
}

// 上传文件
export const upload = {
  uploadFile (playload, cd) {
    return request.post('/app/upload/app', playload, {
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
      },
      onUploadProgress: function (progressEvent) {
        if (progressEvent.lengthComputable) {
          cd(progressEvent)
        }
      }
    })
  }
}

// 应用上架

export const shelves = ({ appEdition, appInfo, fileId, appType, forceUpdate }) => {
  return request.post('/app/grounding', {
    appEdition,
    appInfo,
    fileId,
    appType,
    forceUpdate
  })
}

// 编辑应用

export const updateApp = ({ appId, appInfo, fileId, appType, forceUpdate }) => {
  return request.post('/app/update', {

    appId,
    appInfo,
    fileId,
    appType,
    forceUpdate
  })
}
